package cn.tk.model.pojo.mr.flow;

import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.List;
import java.util.Objects;

/**
 * Created by denglw on 2021/7/16.<br/>
 * Desc: 条件节点对象
 */
@Data @NoArgsConstructor
public class ConditionNodeDTO {

    /**
     * 流程id
     */
    private Long flowId;

    /**
     * 流程节点id
     */
    private Long nodeId;

    /**
     * 打断后是否可恢复：0否 1是
     */
    private Boolean recoverable;

    /**
     * 条件组合规则：1满足以下所有条件 2满足以下任一条件  3不为空的任何输入 4排除已有的其他输入
     */
    private Integer unionRule;

    /**
     * 条件列表
     */
    private List<ConditionDTO> conditions;

    /**
     * 信息采集集合
     */
    private List<ConditionNodeCollect> conditionNodeCollects;

    public ConditionNodeDTO(Long flowId, Long nodeId, Boolean recoverable, Integer unionRule) {
        this.flowId = flowId;
        this.nodeId = nodeId;
        this.recoverable = recoverable;
        this.unionRule = unionRule;
    }

    public boolean isAllRule() {
        return Objects.equals(unionRule, 1);
    }

    public boolean isAnyRule() {
        return Objects.equals(unionRule, 2);
    }

    public boolean isNotNullRule() {
        return Objects.equals(unionRule, 3);
    }

    public boolean isExcludeAllRule() {
        return Objects.equals(unionRule, 4);
    }
}
